﻿using System;
using System.Collections.Generic;
using System.IO;

namespace Map
{
    class Program
    {
        static void Main(string[] args)
        {
            //映射表示 键值对，C#中封装的是 Dictionary
            //实体类映射 是通过实体类获取值，常见的是Dapper

            Console.WriteLine("Pride and Prejudice");


            List<string> words = new FileOperation(Directory.GetCurrentDirectory() + @"\Txt\pride-and-prejudice.txt").readFile();

            Console.WriteLine("Total words: " + words.Count);

            LinkedListMap<string, int> map = new LinkedListMap<string, int>();
            foreach (var word in words)
            {
                if (map.contains(word))
                    map.set(word, map.get(word) + 1);
                else
                    map.add(word, 1);
            }

            Console.WriteLine("Total different words: " + map.getSize());
            Console.WriteLine("Frequency of PRIDE: " + map.get("pride"));
            Console.WriteLine("Frequency of PREJUDICE: " + map.get("prejudice"));

            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();

            Console.WriteLine("Pride and Prejudice");

            Console.WriteLine("Total words: " + words.Count);

            BSTMap<string, int> batmap = new BSTMap<string, int>();
            foreach (var word in words)
            {
                if (batmap.contains(word))
                    batmap.set(word, batmap.get(word) + 1);
                else
                    batmap.add(word, 1);
            }

            Console.WriteLine("Total different words: " + batmap.getSize());
            Console.WriteLine("Frequency of PRIDE: " + batmap.get("pride"));
            Console.WriteLine("Frequency of PREJUDICE: " + batmap.get("prejudice"));

            Console.WriteLine();

        }
    }
}
